package usaco;
/*
ID:toregg1
LANG:JAVA
TASK:milk2
 */

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class milk2 {
	public static void main(String[] args) throws IOException{
		BufferedReader in = new BufferedReader(new FileReader("usaco/milk2.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("usaco/out")));
		
		int cowsNum = Integer.parseInt(in.readLine());
		int[][] times = new int[cowsNum][2];
		String line = null;
		int maxTime = 0;
		int minTime = 1000000;
		for (int i = 0; i < cowsNum; i++) {
			line = in.readLine();
			
			times[i][0] = Integer.parseInt(line.split(" ")[0]);
			times[i][1] = Integer.parseInt(line.split(" ")[1]);
			if(times[i][1] > maxTime){
				maxTime = times[i][1];
			}
			if(times[i][0] < minTime){
				minTime = times[i][0];
			}
		}
		
		boolean[] map = new boolean[maxTime];
		for(int i = 0; i < cowsNum; i++){
			for(int j = times[i][0]; j < times[i][1]; j++){
				map[j] = true;
			}
		}
		
		int maxTrue = 0; int maxFalse = 0;
		int currMaxTrue = 0; int currMaxFalse = 0;
		boolean currElem;
		boolean lastElem = map[minTime];
		System.out.println(minTime + " " + maxTime + " " +map.length);
		
		for (int i = minTime; i < map.length; i++) {
			currElem = map[i];
			if (currElem == lastElem) {
				if(lastElem){
					currMaxTrue++;
					if(currMaxTrue > maxTrue){
						maxTrue = currMaxTrue;
					}
				}else{
					currMaxFalse++;
					if(currMaxFalse > maxFalse){
						maxFalse = currMaxFalse;
					}
				}
			}else{
				lastElem = map[i];
				
				currMaxFalse = 0;
				currMaxTrue = 0;
				i--;
			}
		}
		out.println(maxTrue + " " + maxFalse);
		out.close();
		System.exit(0);
	}
}
